<template>
  <div class="profile">
    <!-- 顶部导航栏 -->
    <div class="nav-bar">
      <van-icon class="back-icon" name="arrow-left" @click="$router.back()"/>
      <div class="service">
        <van-icon class="service-icon" name="service"/>
        <span class="service-text">客服</span>
      </div>
    </div>

    <!-- 用户信息卡片 -->
    <div class="user-card">
      <div class="user-info">
        <div class="avatar">
          <img alt="avatar" src="@/assets/img/user_avatar.jpg"/>
        </div>
        <div class="info">
          <div class="name">
            尊敬的会员
            <van-tag size="small" type="primary">白银贵宾</van-tag>
          </div>
          <div class="level">社区lv.1</div>
        </div>
      </div>
    </div>

    <!-- 订单导航 -->
    <div class="card order-nav">
      <div class="card-header">
        <span class="title">我的订单</span>
        <span class="more">查看全部订单 <van-icon name="arrow"/></span>
      </div>
      <div class="nav-content">
        <div class="nav-item">
          <div class="icon-wrapper">
            <van-icon class="icon" name="notes-o"/>
          </div>
          <span>全部订单</span>
        </div>
        <div class="nav-item">
          <div class="icon-wrapper">
            <van-icon class="icon" name="balance-pay"/>
          </div>
          <span>待付款</span>
        </div>
        <div class="nav-item">
          <div class="icon-wrapper">
            <van-icon class="icon" name="clock-o"/>
          </div>
          <span>未出行</span>
        </div>
        <div class="nav-item">
          <div class="icon-wrapper">
            <van-icon class="icon" name="comment-o"/>
          </div>
          <span>待点评</span>
        </div>
      </div>
    </div>

    <!-- 用户数据 -->
    <div class="card user-data">
      <div class="data-item">
        <div class="num">2</div>
        <div class="label">我的收藏</div>
      </div>
      <div class="data-item">
        <div class="num">5</div>
        <div class="label">浏览历史</div>
      </div>
      <div class="data-item">
        <div class="num">261</div>
        <div class="label">积分</div>
      </div>
      <div class="data-item">
        <div class="num">9</div>
        <div class="label">优惠券</div>
      </div>
    </div>

    <!-- 常用工具 -->
    <div class="card tools">
      <div class="card-header">
        <span class="title">常用工具</span>
      </div>
      <div class="tools-content">
        <div class="tool-item">
          <van-icon class="icon" name="contact"/>
          <span>常用信息</span>
        </div>
        <div class="tool-item">
          <van-icon class="icon" name="clock"/>
          <span>旅行足迹</span>
        </div>
        <div class="tool-item">
          <van-icon class="icon" name="gift"/>
          <span>会员福利</span>
        </div>
        <div class="tool-item">
          <van-icon class="icon" name="service"/>
          <span>在线客服</span>
        </div>
      </div>
    </div>

    <!-- 服务保障 -->
    <service-guarantee use-card/>
  </div>
</template>

<script setup>
import {ref} from "vue";
import {Tag as VanTag} from "vant";
import ServiceGuarantee from "@/components/ServiceGuarantee.vue";

const isLogin = ref(true);
</script>

<style lang="less" scoped>
.profile {
  min-height: 100vh;
  background: #f5f5f5;
  padding-bottom: 20px;

  .nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: transparent;
    z-index: 100;

    .back-icon {
      font-size: 20px;
      color: #333;
    }

    .service {
      display: flex;
      align-items: center;
      gap: 4px;

      .service-icon {
        font-size: 20px;
        color: #333;
      }

      .service-text {
        font-size: 14px;
        color: #333;
      }
    }
  }

  .user-card {
    padding: 60px 16px 20px;
    background: linear-gradient(180deg, #e8f4ff 0%, #fff 100%);

    .user-info {
      display: flex;
      align-items: center;
      gap: 16px;

      .avatar {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        overflow: hidden;
        border: 2px solid rgba(255, 255, 255, 0.8);

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
      }

      .info {
        flex: 1;

        .name {
          font-size: 18px;
          font-weight: 500;
          color: #333;
          margin-bottom: 8px;
          display: flex;
          align-items: center;
          gap: 8px;

          :deep(.van-tag) {
            padding: 0 6px;
            height: 18px;
            line-height: 18px;
            border-radius: 9px;
            font-weight: normal;
          }
        }

        .level {
          display: inline-block;
          font-size: 12px;
          color: #67c23a;
          background: #f0f9eb;
          padding: 2px 8px;
          border-radius: 10px;
        }
      }
    }
  }

  .card {
    margin: 12px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;

    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 16px;
      border-bottom: 1px solid #f5f5f5;

      .title {
        font-size: 15px;
        font-weight: 500;
        color: #333;
      }

      .more {
        font-size: 12px;
        color: #999;
        display: flex;
        align-items: center;
        gap: 2px;

        .van-icon {
          font-size: 12px;
        }
      }
    }
  }

  .order-nav {
    .nav-content {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      padding: 16px 0;
    }

    .nav-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;

      .icon-wrapper {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f5f7fa;
        border-radius: 50%;

        .icon {
          font-size: 22px;
          color: #2c78f5;
        }
      }

      span {
        font-size: 12px;
        color: #333;
      }
    }
  }

  .user-data {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 16px 0;

    .data-item {
      text-align: center;
      position: relative;

      &:not(:last-child)::after {
        content: "";
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 20px;
        background: #eee;
      }

      .num {
        font-size: 18px;
        font-weight: 500;
        color: #333;
        margin-bottom: 4px;
      }

      .label {
        font-size: 12px;
        color: #666;
      }
    }
  }

  .tools {
    .tools-content {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      padding: 16px;
      gap: 16px;

      .tool-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;

        .icon {
          font-size: 24px;
          color: #2c78f5;
        }

        span {
          font-size: 12px;
          color: #333;
        }
      }
    }
  }
}
</style>
